export const ynaGetImg = (name) => {
  try {
    return new URL(`../assets/image/${name}.png`, import.meta.url).href;
  } catch (error) {
    console.log(error);
  }
}

// 是否是移动端
export function isMobile() {
  let userAgentInfo = navigator.userAgent;
  let Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
  let getArr = Agents.filter(i => userAgentInfo.includes(i));
  return getArr.length ? true : false;
}

// 判断客户端
export function judgeClient() {
  let ua = navigator.userAgent;
  let isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1;   //判断是否是 android终端
  let isIOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);     //判断是否是 iOS终端
  if(isAndroid){
    return 'Android';
  }else if(isIOS){
    return 'IOS';
  }else{
    return 'PC';
  }
}

/**
 * 验证手机格式
 */
export function mobile(value) {
  return /^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/.test(value)
}